﻿using System.Windows;
using System.Windows.Input;



namespace Password_manager
{
    /// <summary>
    /// Interaction logic for OptionsDialog.xaml
    /// </summary>
    public partial class OptionsDialog : Window
    {
        UserPrefs prefs;
        int lockDelay;

        public OptionsDialog(UserPrefs prefs_in)
        {
            prefs = prefs_in;

            InitializeComponent();

            slLockDelay.Value = (double)prefs.lockDelay;
        }


        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (lockDelay != prefs.lockDelay)
            {
                prefs.lockDelay = (lockDelay > 10) ? 10 : lockDelay;
                DialogResult = true;
            }
            else DialogResult = false;
            Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }

        private void slLockDelay_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
        {
            lockDelay = (int)slLockDelay.Value;
            if (lockDelay > 10) lockDelay = 10;
        }
    }
}
